<template>
  <div class="vacation-box content-box">
    <nav-title v-if="edit" title="休假申请" :routerLink="routerLink" />
    <nav-title v-else-if="!edit" title="休假审批" :routerLink="routerLink" />
    <div v-if="!type && ((LeaveBalInfo.annDisplay == 'Y') || (LeaveBalInfo.adjDisplay == 'Y'))" class="attendanceCalendar-top">
      <div v-if="LeaveBalInfo.annDisplay == 'Y' && LeaveBalInfo.annDays && ((LeaveBalInfo.annDays/1) > 0)">
        <span></span><span>年假剩余{{LeaveBalInfo.annDays}}天</span>
      </div>
      <div v-if="LeaveBalInfo.adjDisplay == 'Y' && LeaveBalInfo.adjDays && ((LeaveBalInfo.adjDays/1) > 0)">
        <span></span><span>调休剩余{{LeaveBalInfo.adjDays}}天</span>
      </div>
    </div>

    <div class="regulations-box" v-if="!edit">
      <div class="title">基本信息</div>
      <simple-line title="员工ID" v-bind:value="allInfo.cWfEmplid" />
      <simple-line title="姓名" v-bind:value="allInfo.cWfName" />
      <simple-line title="部门" v-bind:value="allInfo.cWfDeptdescr" />
      <simple-line title="岗位" v-bind:value="allInfo.cWfJcDescr" />
      <simple-line title="职等" v-bind:value="allInfo.cWfJobLevel" />
    </div>
    <div class="regulations-box vacation-content">
      <div class="title">流程信息</div>
      <div class="information">
        <edit-option-line :important="true" :boldtitle="true" @on-change="calcDate()" label="请假类型" :readonly="!edit"
          :vals="leaveTypes" v-model="allInfo.cLeaveType" />
        <edit-option-line label="是否跨天" v-if="allInfo.cLeaveType != 'L90'" :important="true" :boldtitle="true" :readonly="!edit"
          :vals="crossDays" v-model="allInfo.cAcrossDay" />
        <edit-date-line :label="allInfo.cAcrossDay == 'Y' ? '开始日期' : '请假日期'" v-if="allInfo.cLeaveType != 'L90'"
          :important="true" :boldtitle="true" :readonly="!edit" v-model="allInfo.startDate" @on-change="startDateChange()" />
        <edit-option-line label="时段" v-if="allInfo.cLeaveType != 'L90' && allInfo.cAcrossDay != 'Y'" :important="true"
          :boldtitle="true" @on-change="calcDate()" :readonly="!edit" :vals="cLeaDay1s" v-model="allInfo.cLeaDay1" />
        <edit-option-line label="时段" v-if="allInfo.cLeaveType != 'L90' && allInfo.cAcrossDay == 'Y'" :important="true"
          :boldtitle="true" @on-change="calcDate()" :readonly="!edit" :vals="cLeaDay2s" v-model="allInfo.cLeaDay2" />
        <edit-date-line label="结束日期" v-if="allInfo.cLeaveType != 'L90' && allInfo.cAcrossDay == 'Y'" :important="true"
          :boldtitle="true" :readonly="!edit" v-model="allInfo.endDate" @on-change="endDataChange()" />
        <edit-option-line label="时段" v-if="allInfo.cLeaveType != 'L90' && allInfo.cAcrossDay == 'Y'" :important="true"
          :boldtitle="true" @on-change="calcDate()" :readonly="!edit" :vals="cLeaDay3s" v-model="allInfo.cLeaDay3" />
        <simple-line title="请休假天数" v-if="allInfo.cLeaveType != 'L90'" v-model="allInfo.cLeaveDays" />
        <edit-option-line label="亲属关系" v-if="allInfo.cLeaveType == 'L70'" :boldtitle="true" :readonly="!edit" :vals="relationships"
          v-model="allInfo.cRelationship" />
        <edit-date-line label="出生日期" v-if="allInfo.cLeaveType == 'L90'" :boldtitle="true" :readonly="!edit" v-model="allInfo.birthdate" />
        <edit-option-line label="请假周期" v-if="allInfo.cLeaveType == 'L90'" :boldtitle="true" :readonly="!edit" :vals="leaveCycles"
          v-model="allInfo.cLeaveCycle" />
        <edit-option-line label="怀孕时长" @on-change="calcDate()" v-if="allInfo.cLeaveType == 'L200'" :important="true"
          :boldtitle="true" :readonly="!edit" :vals="pregnantTimeType" v-model="allInfo.cPregnantTime" />
        <simple-line title="本月已申请产检假" v-if="allInfo.cLeaveType == 'L200'" v-model="this.cPregnantDays+'天'" />
        <!-- <simple-line title="剩余年休假"
        :editting="edit"
        v-if="allInfo.cLeaveType == 'L10'"
        v-bind:value="allInfo.cYearLeaDays"/>
        <simple-line title="剩余调休假"
        :editting="edit"
        v-if="allInfo.cLeaveType == 'L95'"
        v-bind:value="allInfo.cRestLeaDays"/> -->
        <edit-option-line label="家用/商用" v-if="JdLbShow" :boldtitle="true" :readonly="!edit" :vals="jdLbValues" v-model="allInfo.cWfJdLb" />
        <file-line v-if="!edit" label="附件" :fileitems="allInfo.wfFiles" :boldtitle="true" />

        <div class="vacation-interval"></div>
      </div>
    </div>
    <div class="regulations-box">
      <div class="regulations-box">
        <div class="info-label">休假事由</div>
        <div class="info-label-text">
          <textarea v-if="edit" placeholder="请在这里输入..." rows="5" v-model="allInfo.cApplInfo"></textarea>
          <textarea v-else="" readonly rows="5" v-model="allInfo.cApplInfo"></textarea>
        </div>
        <p class="remarks" v-if="allInfo.cLeaveType == 'L20'">
          附件要求：三级以上或公司指定医院的医嘱、病假条
        </p>
        <p class="remarks" v-if="allInfo.cLeaveType == 'L100'">
          附件要求：事故调查登记表
        </p>
        <p class="remarks" v-if="allInfo.cLeaveType == 'L60'">
          附件要求：准生证、结婚证、近期B超
        </p>
        <p class="remarks" v-if="allInfo.cLeaveType == 'L90'">
          附件要求：出生证
        </p>
        <p class="remarks" v-if="allInfo.cLeaveType == 'L40'">
          附件要求：婚假提供结婚证（一年以内可享受），产假提供准生证、围产保健手册（第二页有预产期那页、封面）<br>
          若：准生证没有，附上户口本，围产保健手册没有，附上出院小结）
        </p>
        <p class="remarks" v-if="allInfo.cLeaveType == 'L55'">
          附件要求：婚假提供结婚证（一年以内可享受），产假提供准生证、围产保健手册（第二页有预产期那页、封面）<br>
          (若：准生证没有，附上户口本，围产保健手册没有，附上出院小结）
        </p>
        <p class="remarks" v-if="allInfo.cLeaveType == 'L50'">
          附件要求：准生证、围产保健手册（第二页有预产期那页、封面）<br>
          （若：准生证没有，附上户口本，围产保健手册没有，附上出院小结）
        </p>
        <p class="remarks" v-if="allInfo.cLeaveType == 'L200'">
          享受标准：怀孕1-7个月，每月一天；8-9个月，每月两天；9个月以上每月不超过4天<br>
          附件要求：准生证、工作地所在妇幼保健院或相关产检医院的产检记录
        </p>
      </div>

    </div>
    <div class="regulations-box" v-if="edit">
      <div class="regulations-box">
        <div class="info-label">附件</div>
        <div class="file-list" v-for="item in fileList">
          <div class="filname">
            <span class="iplodimg">
              <a v-if="(item.fileType == 'jpg') || (item.fileType == 'png') || (item.fileType == 'pdf') || (item.fileType=='txt') || (item.fileType=='jpeg')"
                href="javascript:;" @click="showItemClick(item)">{{item.originalName}}</a>
              <!-- <a v-else="" href="javascript:;" @click="downloadFile(item.fileUrl)">{{item.originalName}}</a> -->
              <img class="delicon" v-if="edit" @click="delImg(item.seqnbr)" src="./images/delfil.png">
            </span>
          </div>
        </div>
        <div class="wrap-load" v-if="edit">
          <div class="upload-part">
            <img src="./images/addfils.png">
            <input @change="uploadFile" type="file" name="file" id="file" accept="image/*">
          </div>
        </div>
      </div>
    </div>

    <div class="regulations-box">
      <div class="title">分权引用</div>
      <fqyy-line :editting="edit" :fqyyFlag="fqyyInfo.cFqyyFlag" :noFqyySum="fqyyInfo.noFqyySum" :noFqyyRatio="fqyyInfo.noFqyyRatio"
        :fqyyMsg="fqyyInfo.cFqyyDetail" ref="fqyy"></fqyy-line>
    </div>

    <show-annex :option="showItem" v-if="showDetail" :hiddenImg="hiddenImg"></show-annex>

    <button v-if="resubmit" @click="submit">重新提交</button>
    <button v-else-if="edit" @click="submit">提交</button>
    <!-- 流程图 -->
    <div class="regulations-box" v-if="!edit">
      <div class="title">流程图</div>
      <v-flow-charts :transNum="cTransactionNbr" :loginOprid="loginOprid"></v-flow-charts>
    </div>
    <!-- 审批意见 -->
    <div class="regulations-box" v-if="approved == '0'&&allInfo.cStepType!='C'&& allInfo.cIsChuanyue != 'Y'">
      <div class="info-label">审批意见</div>
      <div class="info-label-text">
        <textarea v-if="approved == '0'" placeholder="请在这里输入..." rows="5" v-model="cComments"></textarea>
        <textarea v-else="" readonly rows="5" v-model="cComments"></textarea>
      </div>
    </div>
    <div style="height: 50px" v-if="!edit"></div>
    <!-- 底部按钮:approveBizType="'formal'"  -->
    <div v-if="approved == '0'">
      <operation-btn :cApprovalSw="allInfo.cApprovalSw" :cDenySw="allInfo.cDenySw" :cPushbackAllSw="allInfo.cPushbackAllSw"
        :cAddSw="allInfo.cAddSw" :cTransactionNbr="allInfo.cTransactionNbr" :cWfType="allInfo.cWfType" :cReadSw="allInfo.cIsChuanyue"
        :cStepType="allInfo.cStepType" :cComments="cComments"></operation-btn>
    </div>
  </div>
</template>

<script>
  import {
  vacationSavePrc,
  calLeaveTime,
  getLeaveLeftShow,
  getWfLaveHdr,
  getWfSelHdr,
  getCompensateApprove,
  getLeaveBalInfo,
  delWfFile,
  calApplyPregnantTime,
  getFqyyInfo,
  saveFqyyInfo
} from "../../api/api";

import CommonUtil from '../../components/basic/util'
import fqyyLine from "../../components/basic/FqyyLine"

import { Datetime, Group, PopupRadio, dateFormat } from "vux";
import FileLine from '../../components/basic/FileLine'
import EditOptionLine from '../../components/basic/EditOptionLine'
import EditDateLine from '../../components/basic/EditDateLine'
import SimpleLine from '../../components/basic/SimpleLine'
import vFlowCharts from "../formalStaff/common/flowChart";
import qs from "qs";
import moment from "moment";
import cloneDeep from "lodash/clonedeep";
import { imgPreview, postImg } from "../../util/uploadImg";
import operationBtn from "../formalStaff/common/operationBtn"
export default {
  name: "Vacation",
  components: {
    Datetime,
    Group,
    PopupRadio,
    vFlowCharts,
    EditOptionLine,
    EditDateLine,
    SimpleLine,
    operationBtn,
    FileLine,
    fqyyLine
  },
  created() {

  },

  mounted() {

    CommonUtil.tryLogin(this).then(()=>{
      this.cTransactionNbr = this.$route.query.cTransactionNbr;
      this.approved = this.$route.query.approved;
      this.loginOprid = this.$route.query.token;
      this.defaultObj = this.initItem();

      this.cWfType = "LAVE";
      if (this.$route.query.approved || this.$route.query.approved == 0) {
        this.edit = false;
      } else {
        this.getMyLeaveBalInfo();
        if (this.$route.query.cTransactionNbr) {
          this.resubmit = true;
        }
      }
      getFqyyInfo({'cTransactionNbr':this.cTransactionNbr,'processType':'vacation'}).then(res => {
          this.fqyyInfo = res.retData;
      })
      if (this.$route.query.cTransactionNbr) {
        this.getData();
      }
      this.emplid = this.$route.query.emplid;
  // C_LEAVE_CYCLE
      if(this.$store.state.bu && this.$store.state.bu=='AUX02'){
        this.JdLbShow = true;
        this.allInfo.cWfJdLb = 'J';
      }
      CommonUtil.loadDic(this.pregnantTimeType, 'C_PREGNANT_TIME', "xlatshortname","fieldvalue")
      CommonUtil.loadDic(this.leaveTypes, 'C_LEAVE_TYPE', "xlatshortname","fieldvalue")
      CommonUtil.loadDic(this.crossDays, 'C_ACROSS_DAY', "xlatshortname","fieldvalue")
      CommonUtil.loadDic(this.cLeaDay1s, 'C_LEA_DAY1', "xlatshortname","fieldvalue")
      CommonUtil.loadDic(this.cLeaDay2s, 'C_LEA_DAY2', "xlatshortname","fieldvalue")
      CommonUtil.loadDic(this.cLeaDay3s, 'C_LEA_DAY3', "xlatshortname","fieldvalue")
      CommonUtil.loadDic(this.relationships, 'C_RELATIONSHIP', "xlatshortname","fieldvalue")
      CommonUtil.loadDic(this.leaveCycles, 'C_LEAVE_CYCLE', "xlatshortname","fieldvalue")
      getLeaveLeftShow().then(res => {if (res && res.retCode === "000000") {this.leftShow == "Y" === res.retData}})
      this.list.push(this.initItem())
    })
  },
  data() {
    return {
      jdLbValues:[{ value: "家用", key: "J" }, { value: "商用", key: "S" }],
      pregnantTimeType:[],
      leaveTypes:[],
      crossDays:[],
      cLeaDay1s:[],
      cLeaDay2s:[],
      cLeaDay3s:[],
      relationships:[],
      leaveCycles:[],

      cPregnantDays:0,//已申请的产检假

      leftShow: false,

      resubmit: false,
      type: false,
      cWfType: "",
      routerLink: "",
      cTransactionNbr: "",
      approved: "",
      edit: true,
      emplid: "",
      leaveInfo: "",
      cComments: "",
      showGroup: false,
      LeaveBalInfo: {},
      showItem: {},
      showDetail: false,
      fileList: [
        // { attachsysfilename: '123.png' }
      ],
      allInfo: {
        cLeaveDays:0
      },
      fqyyInfo:{
        fqyyFlag:'',
        fqyyDetail:''
      },
      defaultObj: {},
      list:[],
      JdLbShow:false
    };
  },
  methods: {
    initItem() {
      return {
        cLeaveType:"",
        cAcrossDay:"N",
        startDate:"",
        cLeaDay1:"",
        cLeaDay2:"",
        endDate:"",
        cLeaDay3:"",
        cLeaveDays:"",
        cRelationship:"",
        birthdate:"",
        cLeaveCycle:"",
        cApplInfo:"",
        // cYearLeaDays:"",
        // cRestLeaDays:""
      }
    },
    getData() {
      this.$vux.loading.show();
      getWfLaveHdr({ cTransactionNbr: this.cTransactionNbr,loginOprid: this.loginOprid })
        .then(res => {
          this.$vux.loading.hide();
          if (res && res.retCode === "000000") {

            CommonUtil.updateFileUrl(res.retData.wfFiles);
            const newRes = Object.assign({}, res.retData);
            newRes.leaves &&
              newRes.leaves.map(item => {
                item.leaveTypeList = this.defaultObj.leaveTypeList;
                // item.leaveType = item.cLeaveType;
                this.defaultObj.leaveTypeList.map(value => {
                  if (value.key == item.leaveType)
                    item.leaveTypeSet = value.type;
                });
                item.timeQuantumList = this.defaultObj.timeQuantumList;
                item.endModeList = this.defaultObj.endModeList;
                this.leaveInfo = newRes.leaveInfo;
                // item.timeQuantum = item.ctimeQuantum;
              });
            this.list = newRes.leaves;
            this.allInfo = res.retData;
            this.leaveInfo = res.retData.leaveInfo;
            this.cWfType = res.retData.cWfType;
            this.fileList = res.retData.wfFiles;
            this.LeaveBalInfo = {
              adjDays: newRes.offLeave,
              adjDisplay: newRes.offDisplay,
              annDays: newRes.annualLeave,
              annDisplay: newRes.annualDisplay
            };
            document.documentElement.scrollTop = 0;
          } else {
            this.$vux.alert.show({
              title: "提示",
              content: res.retMsg
            });
          }
        })
        .catch(res => {
          this.$vux.loading.hide();
          this.$vux.alert.show({
            title: "警告",
            content: "网络异常，请稍后重试"
          });
        });
    },
    getMyLeaveBalInfo() {
      getLeaveBalInfo({ emplid: this.$route.query.emplid,loginOprid: this.loginOprid })
        .then(res => {
          if (res && res.retCode === "000000") {
            this.LeaveBalInfo = res.retData;
          } else {
            this.$vux.alert.show({
              title: "提示",
              content: res.retMsg
            });
          }
        })
        .catch(res => {
          this.$vux.alert.show({
            title: "警告",
            content: "网络异常，请稍后重试"
          });
        });
    },
    leaveTypeChange(index) {
      console.log("leaveTypeChange:" + this.allInfo.cLeaveType)
    },

    startDateChange(index) {
      if(this.edit) {
        if(!this.allInfo.endDate){this.calcPregnantTime(); return;}
        if (
          this.allInfo.cAcrossDay == 'Y' &&
          moment(this.allInfo.endDate).unix() <
          moment(this.allInfo.startDate).unix()
        ) {
          return this.$vux.alert.show({
            title: "提示",
            content: "开始日期必须小于或等于结束日期！",
            onHide: () => {
              this.allInfo.startDate = this.allInfo.endDate;
              this.calcPregnantTime();
            }
          });
        }
        this.calcDate();
      }
    },
    endDataChange(index) {
      if(this.edit) {
        if(!this.allInfo.startDate){return;}
        if (
          this.allInfo.cAcrossDay == 'Y' &&
          moment(this.allInfo.endDate).unix() <
          moment(this.allInfo.startDate).unix()
        ) {
          return this.$vux.alert.show({
            title: "提示",
            content: "结束日期必须大于或等于开始日期！",
            onHide: () => {
              this.allInfo.endDate = this.allInfo.startDate;
            }
          });
        }
        this.calcDate()
      }
    },
    validateItem() {
      let base = CommonUtil.valid(this, this.allInfo, "cLeaveType", "必须选择休假类型！")
        && CommonUtil.valid(this, this.allInfo, "startDate", "必须选择开始日期！")
        && CommonUtil.valid(this, this.allInfo, "cApplInfo", "请填写休假事由！")
      if(!base) {return false}
      if(this.allInfo.cAcrossDay == 'Y') {
        return CommonUtil.valid(this, this.allInfo, "cLeaDay2", "必须选择请假时段！") && CommonUtil.valid(this, this.allInfo, "cLeaDay3", "必须选择请假时段！")
      } else {
        return CommonUtil.valid(this, this.allInfo, "cLeaDay1", "必须选择请假时段！")
      }

    },
    calcDate() {

      let _this = this;
      let v = this.allInfo;

      if(!v.cLeaveType || !v.startDate) {return;}
      if(v.cAcrossDay == 'Y') {
        if(!v.cLeaDay2 || !v.cLeaDay3){return;}
      } else if(v.cAcrossDay == 'N'){
        if(!v.cLeaDay1){return;}
        else{
          if(v.cLeaDay1 == 'C'){
            _this.allInfo.cLeaveDays = "1";
          } else {
            _this.allInfo.cLeaveDays = "0.5";
          }
        }
      }
      calLeaveTime(this.allInfo).then(res => {
        if (res && res.retCode === "000000") {
          _this.allInfo.cLeaveDays = res.retData;
        }
      })
      this.calcPregnantTime();

    },
    //计算怀孕时长
    calcPregnantTime(){
      let _this = this;
      let v = this.allInfo;

      if(v.cLeaveType == 'L200' && v.cPregnantTime && v.startDate){

        //如果是产检假，获取本月已申请的产检假天数
        calApplyPregnantTime(this.allInfo).then(res=>{
          if (res && res.retCode === "000000") {
            _this.cPregnantDays = res.retData;

          }
        })
      }
    },
    submit() {
      if(this.allInfo.cLeaveType != 'L90'){
        if(!this.validateItem()){return;}
      }

      let dayLimit = 1;
      if(this.allInfo.cPregnantTime == 'A') {
          dayLimit = 1;
      } else if(this.allInfo.cPregnantTime == 'B') {
          dayLimit = 2;
      } else if(this.allInfo.cPregnantTime == 'C') {
          dayLimit = 4;
      }
      if((this.cPregnantDays + this.allInfo.cLeaveDays) > dayLimit && this.allInfo.cLeaveType == 'L200'){
        this.$vux.alert.show({
          title: "提示",
          content: "产检假天数超过当月标准"
        });
        return;
      }
      if(parseFloat(this.allInfo.cLeaveDays) > parseFloat(this.LeaveBalInfo.annDays) && this.allInfo.cLeaveType == 'L10'){
        this.$vux.alert.show({
          title: "提示",
          content: "年休假天数不足"
        });
        return;
      }
      if(!this.$refs.fqyy.fqyyFlag1 || (this.$refs.fqyy.fqyyFlag1[0] == '有' && !this.$refs.fqyy.fqyyMsg1)){
        this.$vux.alert.show({
          title: "提示",
          content: "分权信息不能为空"
        });
        return;
      }
      var this2 = this;
      if(this.LeaveBalInfo.adjDays <= '0' && this.allInfo.cLeaveType == 'L95') {
          this.$vux.confirm.show({
            title: "提示",
            content: "您已没有剩余调休天数，请注意!",
            onCancel () {
              return;
            },
            onConfirm () {this2.submitApproval();}
          });
      } else if(parseFloat(this.allInfo.cLeaveDays) > parseFloat(this.LeaveBalInfo.adjDays) && this.allInfo.cLeaveType == 'L95') {
        this.$vux.confirm.show({
          title: "提示",
          content: "您的调休请假天数已大于剩余调休天数，请注意!",
          onCancel () {
            return;
          },
          onConfirm () {this2.submitApproval(); }
        });
      } else {
        this2.submitApproval();
      }

    },
    //提交流程
    submitApproval(){
      this.$vux.loading.show();
      this.allInfo.cTransactionNbr = this.allInfo.cTransactionNbr ? this.allInfo.cTransactionNbr : this.cTransactionNbr;
      vacationSavePrc(this.allInfo)
        .then(res => {
          this.$vux.loading.hide();
          if (res && res.retCode === "000000") {

            //保存分权信息
            saveFqyyInfo({
              cTransactionNbr:res.retData,
              cFqyyFlag:this.$refs.fqyy.fqyyFlag1[0],
              cFqyyDetail:this.$refs.fqyy.fqyyMsg1
            }).then(res => {

            });

            this.$vux.alert.show({
              title: "成功",
              content: "申请成功",
              onHide: () => {
                // this.fileList = [];
                // this.approved = 2;
                // this.routerLink = "MyApplication";
                // this.cTransactionNbr = res.retData;
                // this.edit = false;
                // this.resubmit = false;
                // this.getData();
                this.$router.push({ name:'MyApplication'});
              }
            });
          } else {
            this.$vux.alert.show({
              title: "提示",
              content: res.retMsg
            });
          }
        })
        .catch(res => {
          this.$vux.loading.hide();
          this.$vux.alert.show({
            title: "警告",
            content: "网络异常，请稍后重试"
          });
        });
    },
    addClick(index) {
      this.list.push(this.initItem())
    },
    cutClick(index) {
      this.list.splice(index, 1)
    },

    popGroup() {
      this.showGroup = !this.showGroup;
      window.event.cancelBubble = true;
    },
    delImg(index) {
      delWfFile(
        qs.stringify({ cTransactionNbr: this.cTransactionNbr, seqnbr: index })
      )
        .then(res => {
          if (res.retCode === "000000") {
            const newList = [];
            this.fileList.map(item => {
              if (item.seqnbr != index) newList.push(item);
            });
            this.fileList = newList;
            this.$vux.alert.show({
              title: "提示",
              content: "删除成功"
            });
          } else {
            this.$vux.alert.show({
              title: "提示",
              content: res.retMsg
            });
          }
        })
        .catch(e => {
          this.$vux.loading.hide();
          this.$vux.alert.show({
            title: "提示",
            content: "上传失败"
          });
        });
    },
    showItemClick(item) {
      this.showItem = item;
      this.showDetail = true;
    },
    hiddenImg() {
      this.showDetail = false;
    },
    uploadFile(e) {
      let files = e.target.files || e.dataTransfer.files;
      if (!files.length) return;
      this.picValue = files[0];
      // if(this.picValue.name.length>64) {
      //   this.$vux.alert.show({
      //     title: "提示",
      //     content: "上传文件文件名长度不能超过64位，请修改名字重新上传。"
      //   });
      //   return;
      // }
      this.$vux.loading.show({
        text: "上传中"
      });
      imgPreview(this.picValue).then(imgRes => {
        postImg(imgRes, this.cTransactionNbr, this.cWfType, this.picValue.name)
          .then(res => {
            this.$vux.loading.hide();
            if (res.retCode === "000000") {
              this.cTransactionNbr = res.retData.cTransactionNbr;
              const obj = {
                originalName: this.picValue.name,
                fileUrl: imgRes,
                seqnbr: res.retData.seqnbr,
                fileType: this.picValue.name.split(".")[1]
              };
              this.fileList.push(obj);
              const file = document.getElementById("file");
              file.value = "";
              this.$vux.alert.show({
                title: "提示",
                content: "上传成功"
              });
            } else {
              this.$vux.alert.show({
                title: "提示",
                content: res.retMsg
              });
            }
          })
          .catch(e => {
            this.$vux.loading.hide();
            this.$vux.alert.show({
              title: "提示",
              content: "上传失败"
            });
          });
      });
    },
  }
};
</script>

<style type="text/scss" lang="scss">
  @import "./vacation.scss";
@import "../../styles/rejectmain.scss";
</style>
